﻿<%@ Control Language="C#" AutoEventWireup="true" CodeFile="SchoolYear.ascx.cs" Inherits="Custom_SchoolYear" %>
<script type="text/javascript">
    var schoolYearTerm = Array();
    //当前选中学年
    var GetCurrentYear = 0;
    //当前选中学期
    var GetCurrentTerm = 0;
    var OnChange=null;
    //设置回调
    function SetChange(obj)
    {
        OnChange = obj;
    }
    function startChange()
    {
        GetCurrentYear=event.srcElement.options[event.srcElement.selectedIndex].SchoolYear;
        GetCurrentTerm = event.srcElement.options[event.srcElement.selectedIndex].Term;
        if(OnChange!=null)
        {
            OnChange(GetCurrentYear,GetCurrentTerm);
        }
    }
    function InitSelect(selectId,year,term)
    {
        GetCurrentTerm = term;
        GetCurrentYear = year;
        var sel = document.getElementById(selectId);
        if(sel!=null)
        {
            for(i=0;i<schoolYearTerm.length;i++)
            {
                var oOption = document.createElement("OPTION");
                oOption.text = schoolYearTerm[i].Name;
                oOption.SchoolYear = schoolYearTerm[i].SchoolYear;
                oOption.Term = schoolYearTerm[i].Term;
                if(year == i)
                {
                    oOption.selected = true;
                }
                else
                {
                    oOption.selected = false;
                }
                sel.add(oOption);
            }
        }
    }
</script>
<select id="startYear" onchange="startChange()"></select>
            
<script language="javascript">
 <%
        int index =0;
        foreach(Meqs.Entity.TermInfo y in terms)
        {
            Response.Write("schoolYearTerm["+index+"]={SchoolYear:"+y.SchoolYear+",Term:"+y.Term+",Name:'"+Common.ConvertYearAndTerm(y.SchoolYear,y.Term)+"'};");
            index++;
        }
        if(terms.Count>0)
        {
            Response.Write("InitSelect('startYear',"+terms[0].SchoolYear+","+terms[0].Term+");");
        }
 %>
 </script>